<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>beginWork组件复用</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="../../libs/babel.min.js"></script>
    <script src="../../libs/react-17.0.2.js"></script>
    <script src="../../libs/react-dom-17.0.2.js"></script>
    <script type="text/babel">
      const Comp211 = props => {
        return <div>this is Comp211</div>
      }
      const Comp221 = props => {
        const [num, setNumber] = React.useState(1)
        const handleClickBtn = () => {
          setNumber(preNumber => preNumber + 1)
        }
        return (
          <div>
            this is Comp221
            <div>
              <button onClick={handleClickBtn}>点击更新 - {num}</button>
            </div>
            <Comp2211 num={num} />
          </div>
        )
      }
      const Comp2211 = props => {
        return <div>this is Comp2211 --- {props.num}</div>
      }

      const Comp21 = props => {
        return (
          <div className="div-is-21">
            this is Comp21
            <Comp211 />
          </div>
        )
      }
      const Comp22 = props => {
        return (
          <div>
            this is Comp22
            <Comp221 />
          </div>
        )
      }
      const Comp23 = props => {
        return <div>this is Comp23</div>
      }

      const App = props => {
        return (
          <div>
            <Comp21 />
            <Comp22 />
            <Comp23 />
          </div>
        )
      }
      const root = document.getElementById("root")
      ReactDOM.render(<App app={1} />, root)
      console.dir(root)
    </script>
  </body>
</html>
